package com.zhl.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zhl.model.Favorite;
import com.zhl.service.FavoriteService;

@Controller
public class SpringController {
	
	@Autowired
	FavoriteService favorite;
	
	@RequestMapping("/")
	public String hitu(Model model) 	{

		
	    List<Favorite> a= favorite.findAll(); 

	    model.addAttribute("list",a);
	    
	    return "a";
	
	    
	}
	@RequestMapping("/index")
	public void  index(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException	{
		response.setHeader("content-type", "text/html;charset=UTF-8");
	    response.setCharacterEncoding("UTF-8");
	
	    response.getWriter().println("<h1>打南边来了个喇嘛，手里提拉着五斤鳎犸。<br>"
	    		+ "打北边来了个哑巴，腰里别着个喇叭。<br>"
	    		+ "南边提拉着鳎犸的喇嘛要拿鳎犸换北边别喇叭哑巴的喇叭。<br>"
	    		+ "哑巴不愿意拿喇叭换喇嘛的鳎犸，喇嘛非要换别喇叭哑巴的喇叭。<br>"
	    		+ "喇嘛抡起鳎犸抽了别喇叭哑巴一鳎犸，哑巴摘下喇叭打了提拉着鳎犸的喇嘛一喇叭。<br>"
	    		+ "也不知是提拉着鳎犸的喇嘛抽了别喇叭哑巴一鳎犸，<br>"
	    		+ "还是别喇叭哑巴打了提拉着鳎犸的喇嘛一喇叭。<br>"
	    		+ "喇嘛炖鳎犸，哑巴嘀嘀哒哒吹喇叭</h1>");
  
	}	


}
